﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SeriesWatcher.DataModel;

namespace SeriesWatcher
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void menu1_Clicked(object sender, EventArgs e)
        {
            MessageBox.Show("click");
        }

        private void Start_Click(object sender, EventArgs e)
        {
            SerialManager manager = new SerialManager();

            Serial serial = manager.AddSerial("Neco");
            Serial serial2 = manager.AddSerial("Neco2");
            manager.AddSerial("Neco2");
            manager.AddSerial("Neco2");
            manager.AddSerial("Neco2");
            manager.AddSerial("Neco2");
            manager.AddSerial("Neco2");
            manager.AddSerial("Neco2");
            manager.AddSerial("Neco2");
            manager.AddSerial("Neco2");
            manager.AddSerial("Neco2");
            manager.AddSerial("Neco2");

            foreach (Serial ser in manager.Serials)
            {
                for (int i = 1; i <= 6; i++)
                {
                    Season season = ser.AddSeason(i);
                    if (season != null)
                    {
                        for (int j = 1; j <= 22; j++)
                        {
                            Episode episode = season.AddEpisode(j, "hdtv-lol");
                            if (episode != null)
                            {
                                episode.Name = "Kapitola " + j.ToString() + ".";
                                episode.Date = DateTime.Today.AddDays(7 * (j - 1));
                            }
                        }
                    }
                }
            }

            foreach (Serial ser in manager.Serials)
            {
                TreeNode root = treeView1.Nodes.Add(String.Format(Resource1.TreeSerial, ser.Name, ser.StartYear, (ser.Ended ? ser.EndYear.ToString() : "???")));
                foreach (Season s in serial.Seasons)
                {
                    TreeNode node = root.Nodes.Add(String.Format(Resource1.TreeSeason, s.Number.ToString())); 

                    foreach (Episode ep in s.Episodes)
                    {
                        node.Nodes.Add(s.Number.ToString() + "x" + ep.Number.ToString() + " " + ep.Name);
                    }

                }
            }
            MenuItem[] items = new MenuItem[3];
            items[0] = new MenuItem("1");
            items[0].Click += new EventHandler(menu1_Clicked);


            items[1] = new MenuItem("2");
            items[2] = new MenuItem("3");


            treeView1.ContextMenu = new ContextMenu(items);

            manager.SaveToXml("C:\\a.xml");

        }
    }
}
